package com.atguigu.flink.datastramapi.transform;

import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * Created by Smexy on 2023/2/25
 *
 *  union: 合并。
 *          多个同类型的流可以合并为一个流
 */
public class Demo10_Union
{
    public static void main(String[] args) {

        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();

        env.setParallelism(1);

        DataStreamSource<Integer> ds = env.fromElements(1, 2, 3, 4, 5);
        DataStreamSource<Integer> ds1 = env.fromElements(1, 2, 3, 4, 5);
        DataStreamSource<Integer> ds2 = env.fromElements(1, 2, 3, 4, 5);
        DataStreamSource<String> ds3 = env.fromElements("a","b");

        DataStream<Integer> ds4 = ds.union(ds1, ds2);

        ds4.print();


        try {
            env.execute();
        } catch (Exception e) {
            e.printStackTrace();
        }


    }
}
